<?

/* GmModel model class.
 * This class contains data model implementation code.
 *
 */ 
class MetaModel extends AGModel
{
  // model data
  var $data;

  function __construct($modelName) 
  {
    parent::__construct($modelName);
    // your constructor code goes here
    
  }
  
  function applyCheat($type)
  {
    global $config;
    $cheat = $config['cheat'][$type];
    if ($cheat['cost'] > $this->user->localRecord['u_cheatpoints'])
    {
      $result = '<b style="color:red">You do not have enough Cheat Points to buy '.$cheat['txt'].'</b>';
    }
    else
    {
      $result = 'You bought '.$cheat['txt'];
      switch($type)
      {
        case('HP'): {
          $this->character->heal(1000, 'HP');
          break;
        }
        case('AP'): {
          $this->character->heal(1000, 'AP');
          break;
        }
        case('GP'): {
          $this->character->addInventoryById(0, $this->character->level*250);
          break;
        }
        case('CP'): {
          $this->character->stats['statincrease'] += 3;        
          break;
        }
      }
      $this->user->localRecord['u_cheatpoints'] -= $cheat['cost'];
      DB_UpdateDataset('users', $this->user->localRecord);
      $this->character->saveCharacter();
    }
    return($result);
  }

}


?>
